using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using Microsoft.FxCop.Sdk;

namespace CustomRulesVS2013
{
    public class PrefixField : BaseIntrospectionRule
    {
        // Methods
        public PrefixField()
            : base("PrefixField", "CustomRulesVS2013.Rules", typeof(PrefixField).Assembly)
        {
        }

        public override ProblemCollection Check(Member memberField)
        {
            Field field = memberField as Field;
            if (field == null)
            {
                return null;
            }
            if (field != null)
            {
                string name = field.Name.Name.ToString();
                if (this.ContainsPrefixField(name))
                {
                    base.Problems.Add(new Problem(base.GetResolution(new object[] { field.Name.Name.ToString() }), field.Name.Name.ToString()));
                }
            }
            return base.Problems;
        }

        public bool ContainsPrefixField(string Name)
        {
            if (Name.Length <= 1)
            {
                return false;
            }
            return Name.Contains("_");
        }
    }
}

 

 
